package com.ruoyi.model.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.model.service.IEtlPersonDemoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.model.domain.EtlPersonDemo;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 人员模型示例Controller
 * 
 * @author tangyongbo
 * @date 2021-05-19
 */
@RestController
@RequestMapping("/persondemo")
public class EtlPersonDemoController extends BaseController
{
    @Autowired
    private IEtlPersonDemoService etlPersonDemoService;

    /**
     * 查询人员模型示例列表
     */
    @PreAuthorize(hasPermi = "model:personDemo:list")
    @GetMapping("/list")
    public TableDataInfo list(EtlPersonDemo eltPersonDemo)
    {
        startPage();
        List<EtlPersonDemo> list = etlPersonDemoService.selectEtlPersonDemoList(eltPersonDemo);
        return getDataTable(list);
    }

    /**
     * 导出人员模型示例列表
     */
    @PreAuthorize(hasPermi = "model:personDemo:export")
    @Log(title = "人员模型示例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EtlPersonDemo eltPersonDemo) throws IOException
    {
        List<EtlPersonDemo> list = etlPersonDemoService.selectEtlPersonDemoList(eltPersonDemo);
        ExcelUtil<EtlPersonDemo> util = new ExcelUtil<EtlPersonDemo>(EtlPersonDemo.class);
        util.exportExcel(response, list, "人员模型示例数据");
    }

    /**
     * 获取人员模型示例详细信息
     */
    @PreAuthorize(hasPermi = "model:personDemo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(etlPersonDemoService.selectEtlPersonDemoById(id));
    }

    /**
     * 新增人员模型示例
     */
    @PreAuthorize(hasPermi = "model:personDemo:add")
    @Log(title = "人员模型示例", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EtlPersonDemo eltPersonDemo)
    {
        return toAjax(etlPersonDemoService.insertEtlPersonDemo(eltPersonDemo));
    }

    /**
     * 修改人员模型示例
     */
    @PreAuthorize(hasPermi = "model:personDemo:edit")
    @Log(title = "人员模型示例", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EtlPersonDemo eltPersonDemo)
    {
        return toAjax(etlPersonDemoService.updateEtlPersonDemo(eltPersonDemo));
    }

    /**
     * 删除人员模型示例
     */
    @PreAuthorize(hasPermi = "model:personDemo:remove")
    @Log(title = "人员模型示例", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(etlPersonDemoService.deleteEtlPersonDemoByIds(ids));
    }
}
